package com.jspeed.hibernate.dialogservices;


import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "Users")
public class Users {

	private long userId;
	private String userName;
	private Set<Devices> studentPhoneNumbers = new HashSet<Devices>(0);

	public Users() {
		super();
	}

	public Users(String userName, Set<Devices> studentPhoneNumbers) {
		super();
		this.userName = userName;
		this.studentPhoneNumbers = studentPhoneNumbers;
	}

	@Id
	@GeneratedValue
	@Column(name = "USER_ID")
	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	@Column(name = "USER_NAME", nullable = false, length = 100)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "USERS_DEVICE", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "DEVICE_ID") })
	public Set<Devices> getStudentPhoneNumbers() {
		return studentPhoneNumbers;
	}

	public void setStudentPhoneNumbers(Set<Devices> studentPhoneNumbers) {
		this.studentPhoneNumbers = studentPhoneNumbers;
	}
}
